package com.xykj.enterprise.wechat.event.service.ext;

import com.xykj.enterprise.wechat.bean.ext.externalcontact.ExternalContactVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetCorpTagListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetExternalContactBatchVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GetFollowUserListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GroupChatListVo;
import com.xykj.enterprise.wechat.bean.ext.externalcontact.GroupChatVo;
import com.xykj.enterprise.wechat.event.config.ExtClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author george
 * @create 2021-04-21 20:19
 */
@Service
public class ExternalContactServiceImpl implements ExternalContactService {

    @Autowired
    private ExtClient extClient;

    @Override
    public GetFollowUserListVo getFollowUserList(String accessToken) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        return extClient.get("GetFollowUserList", param, GetFollowUserListVo.class);
    }

    @Override
    public GetExternalContactBatchVo getExternalContactBatch(String accessToken, String userid, String cursor, Integer limit) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        param.put("userid", userid);
        param.put("cursor", cursor);
        param.put("limit", limit);
        return extClient.get("GetExternalContactBatch", param, GetExternalContactBatchVo.class);

    }

    @Override
    public ExternalContactVo getExternalContact(String accessToken, String external_userid) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        param.put("external_userid", external_userid);
        return extClient.get("GetExternalContact", param, ExternalContactVo.class);

    }

    @Override
    public GetCorpTagListVo getCorpTagList(String accessToken, String[] tag_id, String[] group_id) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        param.put("tag_id", tag_id);
        param.put("group_id", group_id);
        return extClient.get("GetCorpTagList", param, GetCorpTagListVo.class);

    }

    @Override
    public GroupChatListVo getGroupChatList(String accessToken, String status_filter, String owner_filter_user_list, String cursor, Integer limit) {
        Map<String, Object> params = new HashMap<>();
        params.put("access_token", accessToken);
        params.put("status_filter", status_filter);
        params.put("owner_filter_user_list", owner_filter_user_list);
        params.put("cursor", cursor);
        params.put("limit", limit);
        return extClient.get("GetGroupChatList", params, GroupChatListVo.class);

    }

    @Override
    public GroupChatVo getGroupChat(String accessToken, String chatId) {
        Map<String, Object> params = new HashMap<>();
        params.put("access_token", accessToken);
        params.put("chat_id", chatId);
        return extClient.get("GetGroupChat", params, GroupChatVo.class);

    }

}
